package com.catherine.mvp_base_component.zxing.activity;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.catherine.mvp_base_component.R;
import com.catherine.mvp_base_component.base.BaseComActivity;
import com.catherine.mvp_base_component.utils.ActivityUtil;
import com.catherine.mvp_base_component.zxing.distinguish.ScanTools;

public class ShowImgClickActivity extends BaseComActivity {

    private ImageView mIvImg;

    public static final int RESULT_SHOW_TIME = 52;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_show_image;
    }

    @Override
    protected void initView() {
        mIvImg = findViewById(R.id.show_img);
        topBarTvTitle.setText("识别二维码");
        topBarTvRight.setText("确定");
        String img = getIntent().getStringExtra("img");
        Glide.with(this).load(img).into(mIvImg);

        topBarTvRight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ScanTools.scanCode(mIvImg, new ScanTools.ScanCall() {
                    @Override
                    public void getCode(String code) {
                        Intent resultIntent = new Intent();
                        resultIntent.putExtra("String", code);
                        setResult(RESULT_SHOW_TIME, resultIntent);
                        ActivityUtil.finishActivity(ShowImgClickActivity.this);
                    }
                });
            }
        });
    }

    @Override
    protected void initData() {

    }

    interface OnImgCallBack {
        void onCallBack(String record);
    }

    //    OnImgCallBack onImgCallBack;
//    String photo_path;
//    public   void setOnImgCallBack(OnImgCallBack onImgCallBack,String photo_path)
//    {
//        IntentUtils.JumpToHaveOne(ShowImgClickActivity.class,"img",photo_path);
//        this.onImgCallBack=onImgCallBack;
//        this.photo_path=photo_path;
//    }

}
